package cn.bdqn.dao;

import cn.bdqn.pojo.Product;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author: 苏闻君
 * @Date: Created in 2020/7/14  16:54
 */
@Mapper
public interface ProductDaok {
    /**
     * 查询全部商品
     * @return 商品集合对象
     */
    @Select("select * from product order by id Desc")
    List<Product> selectAll();

    /**
     * 模糊查询商品
     */
    @Select("SELECT * FROM product WHERE commodityname LIKE concat('%',#{commodityname,jdbcType=VARCHAR},'%')")
    List<Product> selectShop(@Param("commodityname") String commodityname);

    /**
     * 商品详情
     * @param id
     * @return
     */
    @Select("SELECT * FROM product WHERE id =#{id}")
    Product selectDuct(@Param("id") Integer id);

    @Update("UPDATE `study`.`product` SET  `stock` = #{stock} WHERE `id` = #{proid};")
    Integer updStock(Integer stock,Integer proid);
}
